-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Sharding): strict type context and return #5933
fix(Sharding): strict type context and return #5933
Conversation
5fc19a7
to
37a9140
Compare
I'm unsure how to properly type the returns because of the worker mode: discord.js/src/sharding/ShardClientUtil.js Lines 92 to 95 in 985d4d6
|
This needs a rebase. |
37a9140
to
669b170
Compare
669b170
to
306cc90
Compare
Can't we just go with this for now, despite the worker mode and potentially wait for an issue in case anyone is using this to send more complicated data? |
What about executing functions that would return a Promise on the shard? promises.push(Promise.resolve(sh[method](...args))); This would work for normal functions and PromiseLike ones so |
Also added tests to make sure they work
Yes, we can go for this for now, and if we wanted to make both consistent, we can always use V8's serialization API, which is what worker threads use, @iCrawl. Nice catch @LosTigeros! I changed the return of the callbacks from |
Please describe the changes this PR makes and why it should be merged:
Right now,
ShardClientUtil#broadcastEval
andShardingManager#broadcastEval
's return types are the same as the callback's, as well as the context passed, however, the context data is serialized, and so is the return type.This PR implements
Serialized
, which fixes this issue by converting rich types into their serialized counterpart.Status and versioning classification: